package org.example.struct.array;

import com.alibaba.fastjson2.JSON;

/**
 * @author liyishan
 * @date 2023/8/23 09:21
 * @apiNote
 */

public class Test01475FinalPrices {

    public static void main(String[] args) {
        int[] prices = {8,4,6,2,3};
        int[] res = test(prices);
        System.out.println(JSON.toJSON(res));
    }

    public static int[] test(int[] prices) {
        int n = prices.length;
        for(int i = 0; i < n; i++){
            for(int j = i+1;j<n;j++){
                if(prices[i] >= prices[j]) {
                    prices[i] -= prices[j];
                    break;
                }
            }
        }
        return prices;
    }
}
